import type { UniverseConstellation } from "./UniverseConstellation";
import type ExcelJs from "@scvzerng/exceljs";

export class UniverseRegion {
  // 星座数组
  constellations: UniverseConstellation[] = []; // 这是一个数字数组，可以包含最多 1000 个元素

  // 描述字符串
  description?: string;

  // 名称字符串
  name!: string;

  // 区域 ID 整数
  region_id!: number;

  static fromRegion(input: any) {
    const universeRegion = new UniverseRegion();
    universeRegion.region_id = input.region_id;
    universeRegion.name = input.name;
    universeRegion.description = input.description;
    return universeRegion;
  }

  static fromSheet(sheet: ExcelJs.Worksheet) {
    const regions: UniverseRegion[] = [];
    sheet.eachRow((row, index) => {
      if (index > 1) {
        const id = row.getCell(1).text!;
        const name = row.getCell(2).text!;
        const region = new UniverseRegion();
        region.region_id = Number(id);
        region.name = name;
        regions.push(region);
      }
    });
    return regions;
  }
}
